package com.haiqi.modules.ship.web;

import com.github.pagehelper.PageInfo;
import com.haiqi.common.annotation.SafeAuthority;
import com.haiqi.common.bean.DataGridBean;
import com.haiqi.common.bean.PageBean;
import com.haiqi.common.persistence.entity.AddShip;
import com.haiqi.common.utils.PageUtils;
import com.haiqi.modules.ship.service.AddShipService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * Created by liuxiayan on 2017/6/20.
 */
@Controller
@RequestMapping("/add/ship")
@SafeAuthority(menuCode = "monitorLocation,companyMonitorLocation")
public class AddShipController {
    @Autowired
    private AddShipService addShipService;
    @RequestMapping("/getAllShip")
    @ResponseBody
    public DataGridBean<AddShip> getAllShip(String shipName, PageBean pageBean, HttpSession session){
        PageUtils.generatePage(pageBean);
        List<AddShip> addShipList = addShipService.getAllShip(shipName);
        PageInfo<AddShip> pageInfo = new PageInfo<>(addShipList);
        DataGridBean<AddShip> gridBean = new DataGridBean<>();
        PageUtils.convertToEasyuiList(pageInfo,gridBean);
        return gridBean;
    }
}
